<template>
  <div>
    <v-indexTop></v-indexTop>
    <div class="rsm-main">
      <div class="r-h2">
        <h1>你就读的学校</h1>
        <span>快速完善简历，理想职位又进一步</span>
      </div>
      <div class="rsm-model">
        <el-form ref="forms" :model="forms" :rules="rules" label-width="80px">
          <el-form-item label="学校名称" prop="school_name">
            <el-input v-model="forms.school_name"></el-input>
          </el-form-item>
          <el-form-item label="招生类别" prop="recruit_type">
            <el-radio-group v-model="forms.recruit_type">
              <el-radio label="统招" border>统招</el-radio>
              <el-radio label="非统招" border>非统招</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="所学专业" prop="birth_date">
            <el-input placeholder="请输入内容" v-model="forms.major" clearable>
            </el-input>
          </el-form-item>
          <el-form-item label="最高学历" prop="education">
            <el-select v-model="forms.education" placeholder="请选择">
              <el-option
                v-for="item in forms.options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="就读日期" prop="begin_date" class="jdrq">
            <el-col :span="11">
              <el-form-item prop="date1">
                <el-date-picker
                  type="date"
                  placeholder="开始日期"
                  v-model="forms.date1"
                  style="width: 100%"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item prop="date2">
                <el-date-picker
                  type="date"
                  placeholder="结束日期"
                  v-model="forms.date2"
                  style="width: 100%"
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-form-item>
          <el-form-item class="tijiao">
            <el-button type="primary" @click="submitForm('forms')"
              >&nbsp;&nbsp;下&nbsp;&nbsp;一&nbsp;&nbsp;步&nbsp;&nbsp;</el-button
            >
            <el-button type="primary" @click="resetForm('forms')"
              >&nbsp;&nbsp;重&nbsp;&nbsp;置&nbsp;&nbsp;</el-button
            >
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import indexTop from "../assemblyPublic/Index-top";
export default {
  data() {
    return {
      forms: {
        school_name: "", //学校名称
        recruit_type: "", //招生类型
        education: "", //学历
        major: "", //专业
        begin_date: "", //开始时间
        end_date: "", //结束时间
        options: [
          {
            value: 3,
            label: "博士",
          },
          {
            value:2,
            label: "硕士",
          },
          {
            value: 1,
            label: "本科",
          },
          {
            value: 0,
            label: "专科",
          },
        ],
      },
      rules: {
        school_name: [
          {
            required: true,
            message: "学校名称不能为空",
            trigger: "blur",
          },
        ],
        recruit_type: [
          {
            required: true,
            message: "必选项",
            trigger: "change",
          },
        ],
        education: [
          {
            required: true,
            message: "学历不能为空",
            trigger: "change",
          },
        ],
        date1: [
          {
            required: true,
            message: "日期不能为空",
            trigger: "blur",
          },
        ],
        date2: [
          {
            required: true,
            message: "日期不能为空",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    submitForm(formsName) {
      this.$refs[formsName].validate((valid) => {
        if (valid) {
          this.$axios({
            method: "POST",
            url: "api/school_set",
            data: this.forms,
          })
            .then((result) => {
              if (result.data.school_case == "ok") {
                this.$router.push({
                  path: "../resumeExperience",
                });
              } else {
                alert("插入失败！");
              }
            })
            .catch((err) => {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
  components: {
    "v-indexTop": indexTop,
  },
};
</script>
<style scoped>
.rsm-main {
  width: 60%;
  background: rgb(253, 253, 253);
  margin: 50px auto;
  padding: 30px 0px;
  border: 1px solid rgb(202, 202, 202);
}
.rsm-model .jdrq {
  width: 100%;
}
.rsm-model .el-form-item {
  width: 48%;
  display: inline-block;
  margin-bottom: 50px;
}
.rsm-model .el-form-item__label {
  text-align: left;
}
.rsm-model .el-input__inner {
  width: 80%;
}
.rsm-model .el-form {
  margin-top: 10%;
  text-align: left;
}

.rsm-model .tijiao {
  margin-top: 10%;
  float: right;
}
.r-h2 {
  width: 250px;
  float: left;
  margin-left: 5%;
  text-align: left;
}
.r-h2 span {
  color: rgb(184, 184, 189);
  font-size: 16px;
}

.rsm-model {
  width: 90%;
  height: 430px;
  margin: 0px auto;
  margin-top: 70px;
}
.rsm-model ul {
  width: 100%;
  background: rgb(87, 25, 145);
  text-align: left;
  font-size: 18px;
}
.rsm-model ul li {
  width: 50%;
  height: 100px;
  float: left;
  margin-top: 20px;
  color: rgb(76, 77, 78);
}
.rsm-model ul li p {
  margin-top: 10px;
  margin-bottom: 10px;
  padding-left: 3px;
}
.next-p {
  width: 100px;
  float: right;
  margin-right: 55px;
  margin-top: 30px;
}
</style>
